package com.more.offer.functioninterface;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

/**
 * @author yinpeng10
 * @desc
 */
public class ConsumerTest {

	public static <T> void forEachMethod(List<T> list, Consumer<T> c){
		for(T i: list){
			c.accept(i);
		}
	}

	public static int functionMethod(int param, Function<Integer, Integer> func) {
		return func.apply(param);
	}

	public static <T> boolean predicateTest(T o , Predicate<Object> predicate) {
		return predicate.test(o);
	}

	public static void main(String[] args) {
		System.out.println(predicateTest(1, Objects::nonNull));
		forEachMethod(Arrays.asList(1,2,3,4,5), (Integer i) -> System.out.println(i * 5) );
		int i = functionMethod(10, (param) -> param * 20);
		System.out.println(i);
	}
}
